package com.bosssoft.setp.model.business.aliance;

import com.bosssoft.setp.handler.AlianceBusinessProxy;
import com.bosssoft.setp.model.business.power.AllianceCourse;
import lombok.Getter;
import lombok.Setter;
import xyz.erupt.annotation.Erupt;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.sub_erupt.Drill;
import xyz.erupt.annotation.sub_erupt.Link;
import xyz.erupt.annotation.sub_field.Edit;
import xyz.erupt.annotation.sub_field.EditType;
import xyz.erupt.annotation.sub_field.View;
import xyz.erupt.annotation.sub_field.sub_edit.ReferenceTableType;
import xyz.erupt.annotation.sub_field.sub_edit.ReferenceTreeType;
import xyz.erupt.annotation.sub_field.sub_edit.Search;
import xyz.erupt.upms.model.base.HyperModel;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * 加盟商实体的类定义
 *
 * @author lin-gaoying
 * @version 1.1
 * @since 1.0
 */
@Erupt(name = "加盟商", dataProxy = AlianceBusinessProxy.class
        ,
        drills = {
                @Drill(title = "授权",
                        link = @Link(
                                column = "id",
                                joinColumn = "alliance.id",
                                linkErupt = AllianceCourse.class
                        )
                )
        })
@Table(name = "setp_aliance_business")
@Entity
@Getter
@Setter
public class AlianceBusiness extends HyperModel {

    @EruptField(
            views = @View(title = "名称",sortable = true),
            edit = @Edit(title = "名称", notNull = true, search = @Search(vague = true))
    )
    private String name;

    @ManyToOne
    @JoinColumn(name = "aliance_business_grade_id")
    @EruptField(
            views = {
                    @View(title = "加盟商等级", column = "alianceBusinessGradeName")
            },
            edit = @Edit(title = "加盟商等级", type = EditType.REFERENCE_TABLE,
                    referenceTableType = @ReferenceTableType(id = "id", label = "alianceBusinessGradeName")
                    , notNull = true, search = @Search(vague = true)
            )
    )
    private AlianceBusinessGrade alianceBusinessGrade;

    @ManyToOne
    @JoinColumn(name = "tree_id")
    @EruptField(
            edit = @Edit(
                    title = "区域",
                    type = EditType.REFERENCE_TREE,
                    referenceTreeType = @ReferenceTreeType(
                            id = "id", label = "name",
                            pid = "parent.id"
                    )
            )
    )
    private AlianceBusinessArea area;

    @EruptField(
            views = @View(title = "地址"),
            edit = @Edit(title = "地址", notNull = true)
    )
    private String address;

    @EruptField(
            views = @View(title = "负责人"),
            edit = @Edit(title = "负责人", notNull = true)
    )
    private String principal;

    @EruptField(
            views = @View(title = "电话"),
            edit = @Edit(title = "电话", notNull = true)
    )
    private String phoneNumber;

    @EruptField(
            views = @View(title = "邮箱"),
            edit = @Edit(title = "邮箱", notNull = true)
    )
    private String mailbox;

}
